import {
  IndexModel
} from '../../models/index.js';

import {
  GoodsModel
} from '../../models/goods.js';

const indexModel = new IndexModel();
const goodsModel = new GoodsModel();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    banner: [],
    channel: [],
    brandList: [],
    categoryList: [],
    newGoodsList: [],
    hotGoodsList: [],
    topicList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    indexModel.getIndexData().then(res => {
      this.setData({
        banner: res.data.banner,
        channel: res.data.channel,
        brandList: res.data.brandList,
        categoryList: res.data.categoryList,
        newGoodsList: res.data.newGoodsList,
        hotGoodsList: res.data.hotGoodsList,
        topicList: res.data.topicList
      })
    })

    goodsModel.getGoodsCount().then(res => {
      this.setData({
        goodsCount: res.data.goodsCount
      })
    })
  }
})